﻿using System;
using System.Collections.Generic;
using InvestmentIntelligence.DbModel.Models;

namespace InvestmentIntelligence.Data.Repository.Comparers.EntityModelsComparers
{
    public class EconomicSectorCodeComparer : IEqualityComparer<EconomicSector>
    {
        public bool Equals(EconomicSector x, EconomicSector y)
        {
            return x.SectorId == y.SectorId &&
                   x.ParentId == y.ParentId;
        }

        public int GetHashCode(EconomicSector obj)
        {
            return obj.Id;
        }
    }

    public class EconomicSectorDescriptionCodeComparer : IEqualityComparer<EconomicSector>
    {
        public bool Equals(EconomicSector x, EconomicSector y)
        {
            return string.Equals(x.Description, y.Description,
                                 StringComparison.InvariantCultureIgnoreCase);
        }

        public int GetHashCode(EconomicSector obj)
        {
            return string.IsNullOrEmpty(obj.Description) ? 0 : obj.Description.GetHashCode();
        }
    }
}